package com.example.product.mapper;


import com.example.model.product.dto.CategoriesGoodVO;
import com.example.model.product.dto.GoodsDetailVO;
import com.example.model.product.pojo.BnnerImage;
import com.example.model.product.pojo.Goods;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface GoodsMapper {

    /**
     * 查找1级分类
     * @return
     */
    @Select("select * from sm.categories")
    List<CategoriesGoodVO> selectCatrgories();

    @Select("select * ,product_id as id from sm.goods where category_id = #{id}")
    List<Goods> selectGoods(String id);

    /**
     * 查找不同分类的商品
     * @return
     */
    @Select("select *,product_id as id from sm.goods where category_id = #{id}")
    List<Goods> selectDiffrentCategoriesGoods(String id);

    /**
     * 轮播图
     * @return
     */
    @Select("select * ,image_url as imgUrl from sm.bannerimage")
    List<BnnerImage> selectBnnerimage();
    /**
     * 新鲜好物
     * @return
     */
    @Select("SELECT *,product_id as id FROM sm.goods\n" +
            "ORDER BY product_id DESC\n" +
            "LIMIT 4;\n ")
    List<Goods> selectNewsGoods();

    /**
     * 人气好物
     * @return
     */
    @Select("select * from goods order by order_num desc limit 4")
    List<Goods> selectHotGoods();

    @Select("select *,product_id as id from sm.goods where product_id = concat('',#{id},'')")
    GoodsDetailVO selectGoodsDetail(String id);

}
